package com.hms.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * 行业信息. <br>
 * 类详细说明.
 * <p>
 * Copyright: Copyright (c) 2013-4-13 上午10:32:26
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * 
 * @author wangpz@c-platform.com
 * @version 1.0.0
 */
@Entity
@Table(name = "td_industry")
public class TdIndustry extends BaseEntity {

	/** serialVersionUID */
	private static final long serialVersionUID = 1L;

	// 行业名称
	private String name;
	// 树路径
	private String path;
	// 父行业
	private TdIndustry parentIndustry;
	// 子行业
	private Set<TdIndustry> childrenIndustries;

	@Column(name = "name", nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "path", nullable = false)
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@Cascade(value = { CascadeType.DELETE })
	@JoinColumn(name = "parentId")
	public TdIndustry getParentIndustry() {
		return parentIndustry;
	}

	public void setParentIndustry(TdIndustry parentIndustry) {
		this.parentIndustry = parentIndustry;
	}

	@OneToMany(mappedBy = "parentIndustry", fetch = FetchType.LAZY)
	@OrderBy(" name asc")
	public Set<TdIndustry> getChildrenIndustries() {
		return childrenIndustries;
	}

	public void setChildrenIndustries(Set<TdIndustry> childrenIndustries) {
		this.childrenIndustries = childrenIndustries;
	}
}
